import { Navigate, useRoutes } from 'react-router-dom';
import { RouteObject } from '@/router/interface';
import { lazyComponent } from '@/components/lazyComponent';
import Layout from '@/components/Layout'

export const rootRouter: RouteObject[] = [
  {
    path: '/',
    element: <Navigate to="/weather" />,
  },
  {
    element: <Layout />,
    children: [
      {
        path: '/weather',
        element: lazyComponent(() => import('@/pages/weather'))
      },
    ],
	},
  {
    path: '*',
    element: <Navigate to="/404" />,
	},
	{
    element: <Layout />,
    children: [
      {
        path: '/404',
        element: lazyComponent(() => import('@/pages/notFoundPage'))
      },
    ],
  },
];

const Router = () => {
  const routes = useRoutes(rootRouter);
  return routes;
};

export default Router;
